home *** CD-ROM | disk | FTP | other *** search
/ Day Cry / Day Cry CD.bin / oh_towns / taropyon / silib / silib.lzh / PRG / SDKFS / FSELINI.C < prev    next >
C/C++ Source or Header  |  1993-12-05  |  3KB  |  122 lines

  1. /*************************************************************************
  2. *    âtâ@âCâïâZâîâNâ^
  3. *************************************************************************/
  4.  
  5. #include    <stdio.h>
  6. #include    <stdarg.h>
  7. #include    <stdlib.h>
  8. #include    <string.h>
  9.  
  10. #include    <silib.h>
  11. #include    <sifs.h>
  12.  
  13. #include    "sdkfs.h"
  14. #include    "sdkfscf.h"
  15.  
  16. #define    SBATT    (SB_ATT_VERTICAL | SB_ATT_MAXADJUST | SB_ATT_DRAGSLD | SB_ATT_BTNREP)
  17.  
  18. /*************************************************************************
  19. *    âtâ@âCâïâZâîâNâ^é╠âIü[âvâô
  20. *************************************************************************/
  21.  
  22. FILESEL_T    *FileSel_open(void)
  23. {
  24.     FILESEL_T    *fs;
  25.  
  26.     if ( (fs = SI_CALLOC(sizeof(FILESEL_T),1)) == NULL )
  27.         return (NULL);
  28.     fs->dlg   = BLKDLG_open( fsFunc_dlgdsp, fs );
  29.     fs->ev    = EV_workAlloc(NULL,8);
  30.     fs->evDrv = EV_workAlloc(fs->ev,26);
  31.     fs->evFn  = EV_workAlloc(fs->ev,FSDSP_FNUM);
  32.     fs->sb    = SB_open( SBATT, NULL, fsFunc_sbar, fs );
  33.     SB_ev_workAlloc( fs->sb, fs->ev);
  34.     if ( !fs->dlg || !fs->ev || !fs->evDrv || !fs->evFn || !fs->sb )
  35.     {
  36.         if ( fs->dlg )        BLKDLG_close(fs->dlg);
  37.         if ( fs->ev )        EV_workFree(fs->ev);
  38.         if ( fs->evDrv )    EV_workFree(fs->evDrv);
  39.         if ( fs->evFn )        EV_workFree(fs->evFn);
  40.         if ( fs->sb )        SB_close(fs->sb);
  41.         SI_FREE(fs);
  42.         return (NULL);
  43.     }
  44.  
  45.     fs->err        = FSERR_UNREAD;
  46.     fs->drv        = FS_getdrv();
  47.     FS_getdir2(fs->whare);
  48.     fs->dlg->rect.xs = FSDLG_XS;
  49.     fs->dlg->rect.ys = FSDLG_YS;
  50.  
  51.     fs->sort = FSSORT_FILE | FSSORT_DIRTOP;
  52.     fs->posMark = -1;
  53.  
  54.     return (fs);
  55. }
  56.  
  57. /*************************************************************************
  58. *    âtâ@âCâïâZâîâNâ^é╔âNâìü[âY
  59. *************************************************************************/
  60.  
  61. void    FileSel_close( FILESEL_T *fs )
  62. {
  63.     if ( !fs )
  64.         return;
  65.  
  66.     FileSel_clearFndat( fs );
  67.     if ( fs->title )    SI_FREE(fs->title);
  68.     if ( fs->wild )        SI_FREE(fs->wild);
  69.     if ( fs->dlg )        BLKDLG_close(fs->dlg);
  70.     if ( fs->ev )        EV_workFree(fs->ev);
  71.     if ( fs->evDrv )    EV_workFree(fs->evDrv);
  72.     if ( fs->evFn )        EV_workFree(fs->evFn);
  73.     if ( fs->sb )        SB_close(fs->sb);
  74.     SI_FREE(fs);
  75. }
  76.  
  77.  
  78. /*************************************************************************
  79. *    â^âCâgâïé╠É▌ÆΦ
  80. *************************************************************************/
  81.  
  82. int        FileSel_setTitle( FILESEL_T *fs, CONST char *form, ... )
  83. {
  84.     char    tmp[BUFSIZ];
  85.     va_list    arg;
  86.  
  87.     va_start(arg,form);
  88.     vsprintf(tmp,form,arg);
  89.     va_end(arg);
  90.     if ( fs->title )
  91.         SI_FREE(fs->title);
  92.     if ( (fs->title = SI_MALLOC(strlen(tmp)+1)) == NULL )
  93.         return (ERR);
  94.     strcpy( fs->title, tmp );
  95.     return (NORMAL);
  96. }
  97.  
  98. /*************************************************************************
  99. *    âÅâCâïâhâJü[âhé╠É▌ÆΦ
  100. *************************************************************************/
  101.  
  102. int        FileSel_setWild( FILESEL_T *fs, CONST char *wild )
  103. {
  104.     if ( fs->wild )
  105.         SI_FREE(fs->wild);
  106.     if ( (fs->wild = SI_MALLOC(strlen(wild)+1)) == NULL )
  107.         return (ERR);
  108.     strcpy( fs->wild, wild );
  109.     return (NORMAL);
  110. }
  111.  
  112. /*************************************************************************
  113. *    ôⁿù═âtâ@âCâïû╝é╠ĵô╛
  114. *************************************************************************/
  115.  
  116. char    *FileSel_getFn( FILESEL_T *fs )
  117. {
  118.     if ( !fs )
  119.         return ("");
  120.     return (fs->buf);
  121. }
  122.